package com.xinfu.newproject.presenter;

import com.xinfu.newproject.bean.home.bean.GetAppIconBean;
import com.xinfu.newproject.bean.home.body.GetAppIconBody;
import com.xinfu.newproject.callback.MyCallBack;
import com.xinfu.newproject.model.home.HomeModel;
import com.xinfu.newproject.view.IView;

import io.reactivex.disposables.Disposable;

public class HomePresenter {
    private IView.IAppIconView mIAppIconView;

    private HomeModel mHomeModel;

    public HomePresenter(IView.IAppIconView iAppIconView) {
        this.mIAppIconView = iAppIconView;
        mHomeModel = new HomeModel();
    }

    /**
     * 获取首页内容
     */
    public void appIcon() {

        GetAppIconBody getAppIconBody = new GetAppIconBody(mIAppIconView.header(), mIAppIconView.userId());

        mHomeModel.appIcon(getAppIconBody, new MyCallBack<GetAppIconBean>() {
            @Override
            public void onSuccess(GetAppIconBean getAppIconBean) {

                if (getAppIconBean.isSuccess()) {
                    mIAppIconView.getData(getAppIconBean);
                } else {
                    mIAppIconView.showToast(getAppIconBean.getMessage());
                }
//                mISubmitRepairView.showToast(addRepairBean.getMessage());
            }

            @Override
            public void onError(String header, String message) {

                mIAppIconView.showToast(message);
            }

            @Override
            public void onDispose(Disposable disposable) {
                mIAppIconView.closeDispose(disposable);
            }
        });


    }


}
